<template>
  <el-dropdown trigger="click" @command="switchLang">
    <div>
      <svg-icon
        icon-class="language"
        style="
        color: #fff;
        margin-right: 20px;
        width: 20px;
        height: 20px;
        vertical-align: middle;
        cursor: pointer;
      "
      />
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="zh" :disabled="$i18n.locale === 'zh' ">中文</el-dropdown-item>
      <el-dropdown-item command="en" :disabled="$i18n.locale=== 'en'">en</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookies from 'js-cookie'
export default {
  name: 'VueAdminTemplateMasterIndex',

  data() {
    return {
    }
  },

  mounted() {},

  methods: {
    switchLang(type) {
      // 将语言状态保存到本地
      Cookies.set('locale', type)
      // 改变当前的语言
      this.$i18n.locale = type
      this.$message.success('切换语言成功')
    }
  }
}
</script>

<style lang="scss" scoped></style>
